import time
from loguru import logger

from conf.settings import LOG_PATH


class Log:

    def __new__(cls, *args, **kwargs):
        if not hasattr(cls,'instance'):
            cls.instance = super(Log,cls).__new__(cls)
        return cls.instance

    def __init__(self):
        logger.add(rotation='1 MB',sink=f'{LOG_PATH}\\'+'runtime_{time}.log',retention='7 days')

    def debug(self,message):
        logger.debug(message)

    def info(self,message):
        logger.info(message)

    def error(self,message):
        logger.error(message)

    def wraning(self,message):
        logger.warning(message)

log = Log()